package com.ruangong.GitClient.app.YanZhaoWang;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.ruangong.GitClient.YanZhaoWang.Major;
import com.ruangong.GitClient.R;
public class MajorDetails extends AppCompatActivity {
    private TextView textExaminationMethods;
    private TextView textDepartment;
    private TextView textMajor;
    private TextView textResearchDirection;
    private TextView textLearningMethod;
    private TextView textInstructor;
    private TextView textPlannedEnrollment;
    private TextView textExaminationScope;
    private TextView textRemarks;
    private Major currentMajor;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_major_details);

        // 初始化 TextView 和 Button
        textExaminationMethods = findViewById(R.id.textExaminationMethods);
        textDepartment = findViewById(R.id.textDepartment);
        textMajor = findViewById(R.id.textMajor);
        textResearchDirection = findViewById(R.id. textResearchDirection);
        textLearningMethod = findViewById(R.id. textLearningMethod);
        textInstructor = findViewById(R.id. textInstructor);
        textPlannedEnrollment = findViewById(R.id. textPlannedEnrollment);
        textExaminationScope = findViewById(R.id. textExaminationScope);
        textRemarks = findViewById(R.id. textRemarks);
        ImageButton copyLinkButton = findViewById(R.id.buttonCopyLink);


        // 从 Intent 中获取传递的专业对象
        currentMajor = (Major) getIntent().getSerializableExtra("MAJOR");

        // 如果专业对象有效，则显示在界面上
        if (currentMajor != null) {

            textExaminationMethods.setText(currentMajor.getExaminationMethods());
            textDepartment.setText(currentMajor.getDepartment());
            textMajor.setText(currentMajor.getMajor());
            textResearchDirection.setText(currentMajor.getResearchDirection());
            textLearningMethod.setText(currentMajor.getLearningMethod());
            textInstructor.setText(currentMajor.getInstructor());
            textPlannedEnrollment.setText(currentMajor.getPlannedEnrollment());
            textExaminationScope.setText(currentMajor.getExaminationScope());
            textRemarks.setText(currentMajor.getRemarks());
        }

        //设置复制链接按钮的点击事件监听器
        copyLinkButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 复制账号到剪贴板
                ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
                ClipData clip = ClipData.newPlainText("major_remark", currentMajor.getRemarks());
                clipboard.setPrimaryClip(clip);

                // 提示复制成功
                Toast.makeText(MajorDetails.this, "备注信息已复制到剪贴板", Toast.LENGTH_SHORT).show();
            }
        });


    }
}